package com.itheima.backstage.controller;

import com.itheima.backstage.manager.LogManager;
import com.itheima.vo.PageBeanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
public class LogController {

    @Autowired
    private LogManager logManager;

    /**
     * 查询日志列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/findLogList")
    public PageBeanVo findLogList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "15") Integer pageSize,
            Long userId ){

        System.out.println(pageNum+"++++++++"+pageSize+"=========="+userId);
       return logManager.findLogList(pageNum,pageSize, userId);
    }

    /**
     * 删除日志
     * @param id
     */
    @DeleteMapping("/deleteLogById")
    public void deleteLog(
            Long id ){
        System.out.println("=========="+id);
       logManager.deleteLog(id);
    }

    /**
     * 批量删除日志
     * @param ids
     */
    @DeleteMapping("/deleteLog")
    public String  deleteLogList(Long[] ids){
        System.out.println(Arrays.toString(ids));

       logManager.deleteLogList(ids);
       return "0000";
    }








}
